<HTML><HEAD>
<!--

    ------------------------------------------------
    Hello World #7: Saying Hello with a popup Window
    ------------------------------------------------
-->

<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers

/*
    THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
    Copyright (c)1998 by Charles River Media.  All Rights Reserved.
    
    This applet can only be re-used or modifed by license holders of the
    JavaScript Cookbook CD-ROM.  Credit must be given in the source
    code and this copyright notice must be maintained. If you do
    not hold a license to the JavaScript Cookbook, you may NOT
    duplicate or modify this code for your own use.

    Use at your own risk. No warranty is given or implied of the suitability 
    of this applet for any specific application. Neither Erica Sadun nor 
    Charles River Media will be held responsible for any unwanted effects 
    due to the use of this applet or any derivative. 
*/

// --------------------Popup Window---------------------

function PopIt(label, msg)
{
  // Set up Page Colors & Table
  var s1 = 
    "<TITLE>Information!</TITLE>" +
    "<BODY BGCOLOR='ffffff'><TABLE BORDER=0><TR>" +
        "<TD WIDTH=90% HEIGHT=90 VALIGN=TOP ALIGN=LEFT>"+
        "<FONT SIZE=4>"
  
  // Emphasize Label
  var s2 = "<FONT COLOR='FF0000'><B>"+label+"</B></FONT><P>"
 
  // Create a Close Button and Finish Table
  var s3 =   
    "</TD><TD WIDTH=10%> </TD></TR><TR><TD> </TD>"+
    "<TD VALIGN=TOP ALIGN=RIGHT>"+
    "<FORM><INPUT TYPE='BUTTON' VALUE='Okay'" +
                   "onClick='self.close()'>"  +
    "</FORM></TD></TR></TABLE></BODY>"

  // Create the Window
  popup = window.open("","popDialog","height=160,width=300,scrollbars=no")
  popup.document.write(s1+s2+msg+s3)
  popup.document.close()
}

function doHello()
{
  
  PopIt('Hello World!', 'This function allows the JavaScript author to '  +
                 'create a popup window.')
}

<!-- done hiding --></SCRIPT></HEAD>

<BODY bgcolor="ffffff" link="0000ff" vlink="770077">
    
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/UTENS.JPG" WIDTH=80 HEIGHT=50
ALIGN = LEFT>Communications 107</H1></FONT>

<BLOCKQUOTE><FONT COLOR="770000">
    After the reader presses the below button, I'll
    pop up a window to say hello.
    </FONT>

    <FORM>
    <INPUT 
        TYPE="button"
        VALUE="   Say Hello to the Reader   "
        onClick="doHello('Hello World!')"
    ><p>
</FORM></BLOCKQUOTE>
    
<FONT COLOR="007777"><H2>Discussion</H2></FONT>
<FONT SIZE=4>

    This seventh "hello" program uses 
    <FONT COLOR="770000">window.open()</FONT> and
    <FONT COLOR="770000">document.write()</FONT>
    to create a new popup window. The
    <FONT COLOR="770000">window.open()</FONT> call
    creates a new window which is written to by
    a series of <FONT COLOR="770000">document.write()</FONT>s.
    When the writes complete, a <FONT COLOR="770000">document.close()</FONT>
    instructs the window to stop loading new information. The quit
    button works by sending a <FONT COLOR="770000">self.close()</FONT>
    message.  The button's "self" in this case refers to the 
    popup window.  Do not confuse 
    <FONT COLOR="770000">document.close()</FONT> which finishes
    creating a document's contents with <FONT COLOR="770000">
    window.close()</FONT> which closes a physical window.<p>
        
    <h3>Creating a Pop-up Window</h3>
    <font color="770000" size=3><pre><null
    >popup = window.open("","popDialog","scrollbars=no,height=100,width=300")<br><null
    >parent.JChello.document.write(s1+s2+msg+s3)<br><null
    >parent.JChello.document.close()<br><null
    ></pre></font>
    
</FONT>        

<h5>Copyright &copy;1996 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>